package com.shitou.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.shitou.dao.DocumentDao;
import com.shitou.pojo.Document;
import com.shitou.pojo.User;
import com.shitou.util.DateUtil;

@Service
@Transactional
public class DocumentService {

	@Resource
	private DocumentDao documentDao;
	@Resource
	private NewsService newsService;
	
	public int save(Document document, User user) {
		document.setCreatedate(DateUtil.getNow());
		documentDao.save(document);
		newsService.save(document, user);
		return document.getId();
	}

	public Document findById(Integer id) {

		return documentDao.findById(id);
	}

	public Integer edit(Document document, User user) {
		document.setUpdatedate(DateUtil.getNow());
		documentDao.save(document);
		newsService.save(document, user);
		return document.getId();
	}
}
